import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: GodK
 * Date: 2024-03-21
 * Time: 21:37
 */
public class Main {
    public static int removeElement(int[] nums, int val) {
        int n = nums.length;
        int left = 0;
        for (int right = 0; right < n; right++) {
            if (nums[right] != val) {
                nums[left] = nums[right];
                left++;
            }
        }
        return left;
    }
    public static int removeDuplicates(int[] nums) {
        int i = 0;
        int j = 1;
        for(;i<nums.length;i++){
            if(nums[j-1]<nums[i]){
                nums[j]=nums[i];
                j++;
            }
        }
        return j;
    }

    public static void merge(int[] nums1, int m, int[] nums2, int n) {
        int i = m + n - 1;
        while (m > 0 && n > 0) {
            if (nums1[m - 1] < nums2[n - 1]) {
                nums1[i] = nums2[n - 1];
                n--;
            } else {
                nums1[i] = nums1[m - 1];
                m--;
            }
            i--;
        }
        while (m > 0) {
            nums1[i] = nums1[m - 1];
            m--;
            i--;
        }
        while (n > 0) {
            nums1[i] = nums2[n - 1];
            n--;
            i--;
        }
    }
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> ret = new ArrayList<List<Integer>>();
        for (int i = 0; i < numRows; ++i) {
            List<Integer> row = new ArrayList<Integer>();
            for (int j = 0; j <= i; ++j) {
                if (j == 0 || j == i) {
                    row.add(1);
                } else {
                    row.add(ret.get(i - 1).get(j - 1) + ret.get(i - 1).get(j));
                }
            }
            ret.add(row);
        }
        return ret;
    }
    public static void main(String[] args) {
//        int[] arr = {3,2,2,3};
//        System.out.println(removeElement(arr,3));
//        int[] arr = {1,1,2};
//        int[] arr = {0, 0, 1, 1, 1, 2, 2, 3, 3, 4};
//        System.out.println(removeDuplicates(arr));
//          int[] arr1 = {1,2,3,0,0,0};
//          int[] arr2 = {4,5,6};
//          merge(arr1,3,arr2,3);
        /*generate(1);*/
    }
}
